# Contributor: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Ionut Biru <ibiru@archlinux.org>

pkgname=gtksourceview3
pkgver=3.24.11+r28+g73e57b57
pkgrel=1
epoch=1
pkgdesc="A text widget adding syntax highlighting and more to GNOME"
url="https://wiki.gnome.org/Projects/GtkSourceView"
arch=(loong64 x86_64)
license=(GPL)
depends=(gtk3 libxml2)
makedepends=(intltool gobject-introspection vala gtk-doc autoconf-archive
             yelp-tools git)
checkdepends=(xorg-server-xvfb)
options=(debug)
_commit=73e57b5787ac60776c57032e05a4cc32207f9cf6  # gnome-3-24
source=("git+https://gitlab.gnome.org/GNOME/gtksourceview.git#commit=$_commit")
sha256sums=('SKIP')

pkgver() {
  cd gtksourceview
  git describe --tags | sed 's/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  cd gtksourceview

  # Workaround incompat with recent autoconf-archive
  find . -name Makefile.am -exec sed -i '/@CODE_COVERAGE_RULES@/d' {} +

  NOCONFIGURE=1 ./autogen.sh
}

build() {
  cd gtksourceview
  ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
    --disable-static --disable-glade-catalog --disable-gtk-doc --disable-Werror
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

check() {
  cd gtksourceview
  dbus-run-session xvfb-run -s '-nolisten local' make check
}

package() {
  cd gtksourceview
  make DESTDIR="$pkgdir" install
}
